/**
 * 
 */
package com.ubo.graphviz.model.graph;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


import com.ubo.graphviz.model.graph.statement.IStatement;
import com.ubo.transform.dot.DotGenerator;

/**
 * @author saludegu
 * 
 */
public class Graph {

	/**
	 * Nom du graphe.
	 */
	protected final String mName;

	/**
	 * Type du graphe.
	 */
	protected final EGraphType mType;

	/**
	 * Indique si le graphe est un strictDiGraph.
	 */
	protected boolean mStrictDiGraph;

	/**
	 * Représente la liste des statements contenus dans le graphe.
	 */
	protected List<IStatement> mStatements;

	/**
	 * Font utilisée dans le graphe.
	 */
	protected String mFont;

	/**
	 * Nom du fichier contenant le graphe.
	 */
	protected String mFileName;

	/**
	 * 
	 * Constructor
	 * 
	 * @param name
	 * @param type
	 */
	public Graph(String name, EGraphType type) {
		mName = name;
		mType = type;
		mStrictDiGraph = false;
	}

	/**
	 * @return the mStrictDiGraph
	 */
	public boolean isStrictDiGraph() {
		return mStrictDiGraph;
	}

	/**
	 * @param mStrictDiGraph
	 *            the mStrictDiGraph to set
	 */
	public void setStrictDiGraph(boolean mStrictDiGraph) {
		this.mStrictDiGraph = mStrictDiGraph;
	}

	/**
	 * @return the mFont
	 */
	public String getFont() {
		return mFont;
	}

	/**
	 * @param mFont
	 *            the mFont to set
	 */
	public void setFont(String mFont) {
		this.mFont = mFont;
	}

	/**
	 * @return the mFileName
	 */
	public String getFileName() {
		return mFileName;
	}

	/**
	 * @param mFileName
	 *            the mFileName to set
	 */
	public void setFileName(String mFileName) {
		this.mFileName = mFileName;
	}

	/**
	 * @return the mName
	 */
	public String getName() {
		return mName;
	}

	/**
	 * @return the mType
	 */
	public EGraphType getType() {
		return mType;
	}

	/**
	 * @return the mStatements
	 */
	public List<IStatement> getStatements() {
		return mStatements;
	}

	/**
	 * Ajout d'un statement à la liste.
	 * 
	 * @param newStatement
	 */
	public void addStatement(IStatement newStatement) {
		if (mStatements == null)
			mStatements = new ArrayList<IStatement>(1);
		mStatements.add(newStatement);
	}

	/**
	 * Ajout d'une collection de statements.
	 * 
	 * @param statements
	 */
	public void addStatements(Collection<IStatement> statements) {
		if (mStatements == null)
			mStatements = new ArrayList<IStatement>();
		mStatements.addAll(statements);
	}

	/**
	 * @param dotGenerator
	 */
	public void generate(DotGenerator dotGenerator) {
		dotGenerator.generate(this);
	}
}
